class GrabsController < ApplicationController
  # GET /grabs
  # GET /grabs.xml
  def index
    @grabs = Grab.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @grabs }
    end
  end

  # GET /grabs/1
  # GET /grabs/1.xml
  def show
    @grab = Grab.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @grab }
    end
  end

  # GET /grabs/new
  # GET /grabs/new.xml
  def new
    @grab = Grab.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @grab }
    end
  end

  # GET /grabs/1/edit
  def edit
    @grab = Grab.find(params[:id])
  end

  # POST /grabs
  # POST /grabs.xml
  def create
    @grab = Grab.new(params[:grab])

    respond_to do |format|
      if @grab.save
        flash[:notice] = 'Grab was successfully created.'
        format.html { redirect_to(@grab) }
        format.xml  { render :xml => @grab, :status => :created, :location => @grab }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @grab.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /grabs/1
  # PUT /grabs/1.xml
  def update
    @grab = Grab.find(params[:id])

    respond_to do |format|
      if @grab.update_attributes(params[:grab])
        flash[:notice] = 'Grab was successfully updated.'
        format.html { redirect_to(@grab) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @grab.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /grabs/1
  # DELETE /grabs/1.xml
  def destroy
    @grab = Grab.find(params[:id])
    @grab.destroy

    respond_to do |format|
      format.html { redirect_to(grabs_url) }
      format.xml  { head :ok }
    end
  end
end
